package com.ele.web;


import com.ele.pojo.Business;
import com.ele.pojo.PageResult;
import com.ele.service.BusinessService;
import com.ele.service.impl.BusinessServiceImpl;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/findBusiness")
public class BusinessAllServlet extends HttpServlet {
    private BusinessService businessService = new BusinessServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String account = req.getParameter("account");
        System.out.println(account);
        String contact = req.getParameter("contact");
        String telephone = req.getParameter("telephone");
        String currentPage = req.getParameter("currentPage");
        String pageSize = req.getParameter("pageSize");
        PageResult<List<Business>> businessServiceAll = this.businessService.findAll(account,contact,telephone,currentPage,pageSize);
        Gson gson = new Gson();
        String json = gson.toJson(businessServiceAll);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(json);
    }
}
